<?php

$dsn = 'mysql:host=127.0.0.1;dbname=Tingjun;charset=utf8';
$pdo = new PDO($dsn, 'root', '');

$sql = 'SELECT `id` FROM `stu` LIMIT 8';
$res = $pdo->query($sql);
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
    echo $row['id'] . '<br>';
}
?>